package com.zzq.service.impl;

import com.zzq.domain.dto.SmileShootRecordDTO;
import com.zzq.domain.entity.SmileShootRecord;
import com.zzq.domain.search.ShootRecordSearchParament;
import com.zzq.mapper.SmileShootRecordMapper;
import com.zzq.service.SmileShootRecordService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 谢文宗
 * @since 2023-09-09
 */
@Service
public class SmileShootRecordServiceImpl extends ServiceImpl<SmileShootRecordMapper, SmileShootRecord> implements SmileShootRecordService {


    @Autowired
    SmileShootRecordMapper smileShootRecordMapper;
    @Override
    public List<SmileShootRecordDTO> getSmileShootRecordDTOs(ShootRecordSearchParament searchParament) {
        return         smileShootRecordMapper.getSmileShootRecordDTOs(searchParament);
    }

    @Override
    public BigDecimal getRecordAmout(ShootRecordSearchParament searchParament) {
        List<SmileShootRecordDTO> smileShootRecordDTOs = smileShootRecordMapper.getSmileShootRecordDTOs(searchParament);
        BigDecimal reduce = smileShootRecordDTOs.stream().map(SmileShootRecordDTO::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
        return reduce;
    }
}
